Component({
  methods: {
    handleTap() {
      wx.login({
        success: ({code}) => {
          wx.request({
            url: 'http://localhost:3000/auth',
            method: 'post',
            data: {
              code
            },
            success: (result) => {
              wx.setStorageSync('token', result.data)
            }
          })
        }
      })
    },

    handlePageTap() {
      const token = wx.getStorageSync('token')
      if(token) {
        wx.request({
          url: 'http://localhost:3000/isAuth',
          method: 'post',
          data: {
            token
          },
          success: (result) => {
            console.log(result)
          }
        })
      } else {
        console.log('fail')
      }
    },


    handleGetPho(e) {
      console.log(e)
    },

    getUserInfo(e) {
      console.log(e.detail.userInfo)
    }
  }
})
